package com.example.goandpaytthebill.Fragment;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.goandpaytthebill.Adapter.LauncherViewPagerSYNewAdapter;
import com.example.goandpaytthebill.Bean.BannerListBean;
import com.example.goandpaytthebill.Bean.GetStoreCategoryListBean;
import com.example.goandpaytthebill.Bean.GetStoreListListBean;
import com.example.goandpaytthebill.Bean.RecommendStoreListBean;
import com.example.goandpaytthebill.Bean.recommendGoodsListBean;
import com.example.goandpaytthebill.R;
import com.example.goandpaytthebill.ServerApi;
import com.example.goandpaytthebill.Tool.CustomRoundAngleImageView;
import com.example.goandpaytthebill.Tool.MyScrollView;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
import com.scwang.smartrefresh.layout.footer.BallPulseFooter;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.squareup.picasso.Picasso;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import okhttp3.Call;

import static android.content.Context.MODE_PRIVATE;

public class NewHomePageFragment extends Fragment {


    private View viewS;

    private String userid;
    private String city;
    private String type_sy;
    private String city1;
    private ArrayList details_list = new ArrayList<String>();
//    private ArrayList<GetIndexInfoBeanNewBean> GetCartItemPlistBeanList = new ArrayList<>();
//    private ArrayList<GetIndexShopListBean> GetIndexShopListBeanList = new ArrayList<>();
    private ArrayList<recommendGoodsListBean> recommendGoodsListBeanList = new ArrayList<>();
    private ArrayList<RecommendStoreListBean> RecommendStoreListBeanList = new ArrayList<>();
    private ArrayList<GetStoreCategoryListBean> GetStoreCategoryListBeanList = new ArrayList<>();
    private ArrayList<GetStoreListListBean> GetStoreListListBeanList = new ArrayList<>();
    private ArrayList<BannerListBean> BannerListBeanList = new ArrayList<>();
//    private ArrayList<GetIndexInfoBeanNewBean> outlinesGetIndex;
    private ViewPager Viewpager_sy;
    private LinearLayout vp_layout;
    private Context mContext;
    private int viewPagerItemSize = 0;
    private LauncherViewPagerSYNewAdapter mViewPagerAdapter;
    private ImageView[] dotImageViews;
    private PageChangeListenerImpl mPageChangeListenerImpl;
    private Handler mHandler;
    private final static int SET_VIEWPAGER_ITEM = 0;
    private Runnable mRunnable;
    private final int INTERVAL = 1000 * 3;
//    private LocationClient mLocationClient;
//    public BDLocationListener myListener = new MyLocationListener();
    private TextView city_sy;
    private String Latitude;
    private String Longitude;
    private RecyclerView RecyclerView_homepage_new;
//    private page_Adapter adaptertuijian;
    private ImageView iv_page;
    private RelativeLayout rl_midet;
    private ImageView iv_midet1;
    private ImageView iv_midet2;
    private LinearLayoutManager layoutManager2;
    private RecyclerView mr_recyclerView;
    private Mr_Adapter mr_adapter;
    private LinearLayoutManager layoutManager6;
    private Mr1_Adapter mr1_adapter;
    private RecyclerView RecyclerView_jingxuan;
    private LinearLayout five;
    private RecyclerView tuijian_md_recyclerView;
//    private Fltuijian_Adapter adaptertuijian1;
    private Button bt_jvli;
    private Button bt_zonghe;
    private Button bt_pingfen;
    private Button bt_xiaoliang;
    private int page = 1;
    private int pxtype = 0;
    private SmartRefreshLayout page_RefreshLayout;


    private Button bt_zonghe_table;
    private Button bt_jvli_table;
    private Button bt_xiaoliang_table;
    private Button bt_pingfen_table;
    private LinearLayout ll_table;
    private MyScrollView page_ScrollView;
    private LinearLayout rl_hight;
    private LinearLayout one_rl;
    private LinearLayout two_ll;
    private LinearLayout four_ll;
    private LinearLayout five_ll;
    private int inoe = 0;
    private int itwo = 0;
    private int ithree = 0;
    private int ifour = 0;
    private ImageView iv_zd;
//    private RelativeLayout loading_rl;
//    private AVLoadingIndicatorView avi;
    private LinearLayout main_page_ss;
    private ImageView sm_iv;
    private static final int REQUEST_CODE_SCAN_ONE = 0X01;
    public static final int CAMERA_REQ_CODE = 111;
    public static final int DECODE = 1;
    private LinearLayout LL_sy;
//    private Fltuijian_Adapter adaptertuijian1;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        viewS = inflater.inflate(R.layout.activity_new_home_page_fragment, container, false);
        setView();
//        startLocate();

//        GetIndexInfo();
//        GetIndexShopList();
        GetStoreListList();
        RecommendGoodsList();
        RecommendStoreList();
        GetStoreCategoryList();
        BannerList();
        return viewS;
    }

    private void GetStoreListList() {
        OkHttpUtils
                .post()
                .url(ServerApi.getStoreList)
                .build()
                .execute(new StringCallback() {
                    private page_Adapter adaptertuijian;
                    private JSONArray ary;
                    private String data;
                    private String message;
                    private String codes;

                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        try {
                            codes = new JSONObject(response).getString("code");

                            message = new JSONObject(response).getString("message");


                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        if (codes.equals("1")) {
                            details_list = new ArrayList<>();
                            details_list.add(response);
                            Gson gson = new Gson();
                            ArrayList<GetStoreListListBean> outlinesGetIndexshop = gson.fromJson(String.valueOf(details_list), new TypeToken<ArrayList<GetStoreListListBean>>() {
                            }.getType());
                            for (int i = 0; i < outlinesGetIndexshop.size(); i++) {
                                GetStoreListListBean appoIntInfoBean = outlinesGetIndexshop.get(i);
                                GetStoreListListBeanList.add(new GetStoreListListBean(
                                        appoIntInfoBean.getCode(),
                                        appoIntInfoBean.getData(),
                                        appoIntInfoBean.getMsg(),
                                        appoIntInfoBean.getTime()

                                ));
                            }

                        } else {
                            Toast.makeText(viewS.getContext(), message, Toast.LENGTH_SHORT).show();
                        }

                    }
                });
    }

    //轮播图网络请求
    private void BannerList() {
        OkHttpUtils
                .post()
                .url(ServerApi.bannerList)
                .build()
                .execute(new StringCallback() {
                    private JSONArray ary;
                    private String data;
                    private String message;
                    private String codes;

                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        try {
                            codes = new JSONObject(response).getString("code");
                            message = new JSONObject(response).getString("message");


                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        if (codes.equals("1")) {
                            details_list = new ArrayList<>();
                            details_list.add(response);

                            Gson gson = new Gson();
                            ArrayList<BannerListBean> outlinesGetIndexshop = gson.fromJson(String.valueOf(details_list), new TypeToken<ArrayList<BannerListBean>>() {
                            }.getType());
                            for (int i = 0; i < outlinesGetIndexshop.size(); i++) {
                                BannerListBean appoIntInfoBean = outlinesGetIndexshop.get(i);
                                BannerListBeanList.add(new BannerListBean(
                                        appoIntInfoBean.getCode(),
                                        appoIntInfoBean.getData(),
                                        appoIntInfoBean.getMsg(),
                                        appoIntInfoBean.getTime()

                                ));
                            }
                            //初始化轮播图
                            init();
                            vp_layout.setVisibility(View.VISIBLE);
                            Viewpager_sy.setVisibility(View.VISIBLE);
                        } else {
                            Toast.makeText(viewS.getContext(), message, Toast.LENGTH_SHORT).show();
                        }

                    }
                });
    }
    //获取门店分类网络请求
    private void GetStoreCategoryList() {
        OkHttpUtils
                .post()
                .url(ServerApi.getStoreCategoryList)
                .build()
                .execute(new StringCallback() {
                    private page_Adapter adaptertuijian;
                    private JSONArray ary;
                    private String data;
                    private String message;
                    private String codes;

                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        try {
                            codes = new JSONObject(response).getString("code");

                            message = new JSONObject(response).getString("message");


                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        if (codes.equals("1")) {
                            details_list = new ArrayList<>();
                            details_list.add(response);

                            Gson gson = new Gson();
                            ArrayList<GetStoreCategoryListBean> outlinesGetIndexshop = gson.fromJson(String.valueOf(details_list), new TypeToken<ArrayList<GetStoreCategoryListBean>>() {
                            }.getType());
                            for (int i = 0; i < outlinesGetIndexshop.size(); i++) {
                                GetStoreCategoryListBean appoIntInfoBean = outlinesGetIndexshop.get(i);
                                GetStoreCategoryListBeanList.add(new GetStoreCategoryListBean(
                                        appoIntInfoBean.getCode(),
                                        appoIntInfoBean.getData(),
                                        appoIntInfoBean.getMsg(),
                                        appoIntInfoBean.getTime()

                                ));
                            }
                            GridLayoutManager layoutManagertj = new GridLayoutManager(viewS.getContext(), 5) {
                                @Override
                                public boolean canScrollVertically() {
                                    return false;

                                }
                            };

                            layoutManagertj.setOrientation(LinearLayoutManager.VERTICAL);
                            RecyclerView_homepage_new.setLayoutManager(layoutManagertj);
                            adaptertuijian = new page_Adapter();

                            RecyclerView_homepage_new.setAdapter(adaptertuijian);
                        } else {
                            Toast.makeText(viewS.getContext(), message, Toast.LENGTH_SHORT).show();
                        }

                    }
                });


    }
    //获取首页发现好店列表网络请求
    private void RecommendStoreList() {
        OkHttpUtils
                .post()
                .url(ServerApi.recommendStoreList)
                .addParams("page","1")
                .addParams("pagesize","20")
                .addParams("lat","")
                .addParams("lng","")
                .build()
                .execute(new StringCallback() {
                    private JSONArray ary;
                    private String data;
                    private String message;
                    private String codes;

                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        try {
                            codes = new JSONObject(response).getString("code");

                            message = new JSONObject(response).getString("message");


                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        if (codes.equals("1")) {
                            details_list = new ArrayList<>();
                            details_list.add(response);

                            Gson gson = new Gson();
                            ArrayList<RecommendStoreListBean> outlinesGetIndexshop = gson.fromJson(String.valueOf(details_list), new TypeToken<ArrayList<RecommendStoreListBean>>() {
                            }.getType());
                            for (int i = 0; i < outlinesGetIndexshop.size(); i++) {
                                RecommendStoreListBean appoIntInfoBean = outlinesGetIndexshop.get(i);
                                RecommendStoreListBeanList.add(new RecommendStoreListBean(
                                        appoIntInfoBean.getCode(),
                                        appoIntInfoBean.getData(),
                                        appoIntInfoBean.getMsg(),
                                        appoIntInfoBean.getTime()

                                ));
                            }
                            five_ll.setVisibility(View.VISIBLE);
                            layoutManager6 = new LinearLayoutManager(viewS.getContext());
                            layoutManager6.setOrientation(LinearLayoutManager.HORIZONTAL);
                            RecyclerView_jingxuan.setLayoutManager(layoutManager6);
                            mr1_adapter = new Mr1_Adapter();
                            RecyclerView_jingxuan.setAdapter(mr1_adapter);

//                            InitShopView();
                        } else {
                            Toast.makeText(viewS.getContext(), message, Toast.LENGTH_SHORT).show();
                        }

                    }
                });
    }
    //首页发现好货列表网络请求
    private void RecommendGoodsList() {
        OkHttpUtils
                .post()
                .url(ServerApi.recommendGoodsList)
                .build()
                .execute(new StringCallback() {
                    private JSONArray ary;
                    private String data;
                    private String message;
                    private String codes;

                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        try {
                            codes = new JSONObject(response).getString("code");

                            message = new JSONObject(response).getString("message");


                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        if (codes.equals("1")) {
                            details_list = new ArrayList<>();
                            details_list.add(response);

                            Gson gson = new Gson();
                            ArrayList<recommendGoodsListBean> outlinesGetIndexshop = gson.fromJson(String.valueOf(details_list), new TypeToken<ArrayList<recommendGoodsListBean>>() {
                            }.getType());
                            for (int i = 0; i < outlinesGetIndexshop.size(); i++) {
                                recommendGoodsListBean appoIntInfoBean = outlinesGetIndexshop.get(i);
                                recommendGoodsListBeanList.add(new recommendGoodsListBean(
                                        appoIntInfoBean.getCode(),
                                        appoIntInfoBean.getData(),
                                        appoIntInfoBean.getMsg(),
                                        appoIntInfoBean.getTime()

                                ));
                            }

                            //发现好店列表适配器初始化

                            layoutManager2 = new LinearLayoutManager(viewS.getContext());
                            layoutManager2.setOrientation(LinearLayoutManager.HORIZONTAL);
                            mr_recyclerView.setLayoutManager(layoutManager2);
                            mr_adapter = new Mr_Adapter();
                            mr_recyclerView.setAdapter(mr_adapter);
//                            InitShopView();
                        } else {
                            Toast.makeText(viewS.getContext(), message, Toast.LENGTH_SHORT).show();
                        }

                    }
                });
    }

    private void InitShopView() {
//        if (page == 1) {
//            //推荐门店列表
//            GridLayoutManager layoutManager2 = new GridLayoutManager(viewS.getContext(), 1) {
//                @Override
//                public boolean canScrollVertically() {
//                    return false;
//
//                }
//            };
//
//            layoutManager2.setOrientation(LinearLayoutManager.VERTICAL);
//            tuijian_md_recyclerView.setLayoutManager(layoutManager2);
//            adaptertuijian1 = new Fltuijian_Adapter();
//            tuijian_md_recyclerView.setAdapter(adaptertuijian1);
//        } else {
//            adaptertuijian1.notifyDataSetChanged();
//        }

    }

    private class page_Adapter extends RecyclerView.Adapter<page_Adapter.ViewHolder> {
        @NonNull
        @Override
        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.like_page, parent, false);

            ViewHolder holder = new ViewHolder(view);
//            int parentHeight = parent.getWidth();
//            parent.getWidth();
//            ViewGroup.LayoutParams layoutParams = holder.itemView.getLayoutParams();
//
//            layoutParams.width = (parentHeight / 5);
            return holder;
        }

        @Override
        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

            holder.tv_page.setText(GetStoreCategoryListBeanList.get(0).getData().get(position).getName());
//
            Picasso.with(viewS.getContext())
                    .load(String.valueOf("http://tbyg-new.oss-cn-beijing.aliyuncs.com/"+GetStoreCategoryListBeanList.get(0).getData().get(position).getPic()))
                    .fit()
                    .into(holder.iv_page);
//            Glide.with(viewS.getContext()).load(String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getIconsrc())).into(holder.iv_page);



        }

        @Override
        public int getItemCount() {
            return GetStoreCategoryListBeanList.get(0).getData().size();
        }

        class ViewHolder extends RecyclerView.ViewHolder {


            private final TextView tv_page;
            private final ImageView iv_page;
            private final LinearLayout page_item;


            public ViewHolder(@NonNull View itemView) {
                super(itemView);
                iv_page = (ImageView) itemView.findViewById(R.id.iv_page);
                tv_page = (TextView) itemView.findViewById(R.id.tv_page);
                page_item = (LinearLayout) itemView.findViewById(R.id.page_item);

            }
        }
    }

    /*
     * 门店列表适配器
     * */

//    private class Fltuijian_Adapter extends RecyclerView.Adapter<Fltuijian_Adapter.ViewHolder> {
//
//
//        private SyLinearLayoutManager layoutManager_lable;
//        private lable_Adapter lable_adapter;
//        private SyLinearLayoutManager layoutManager_lable2;
//        private shop_Adapter shop_adapter;
//
//
//        @NonNull
//        @Override
//        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_new_page_shope, parent, false);
//
//            ViewHolder holder = new ViewHolder(view);
//
//            return holder;
//        }
//
//        @Override
//        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//            //lable初始化适配器
//            layoutManager_lable = new SyLinearLayoutManager(viewS.getContext());
//            layoutManager_lable.setOrientation(SyLinearLayoutManager.HORIZONTAL);
//            holder.RecyclerView_lable_new.setLayoutManager(layoutManager_lable);
//            lable_adapter = new lable_Adapter(position);
//            holder.RecyclerView_lable_new.setAdapter(lable_adapter);
//
//            //商品初始化适配器
//            layoutManager_lable2 = new SyLinearLayoutManager(viewS.getContext());
//            layoutManager_lable2.setOrientation(SyLinearLayoutManager.VERTICAL);
//            holder.RecyclerView_shop_new.setLayoutManager(layoutManager_lable2);
//            shop_adapter = new shop_Adapter(position);
//            holder.RecyclerView_shop_new.setAdapter(shop_adapter);
//
//            holder.tuijian_title.setText(String.valueOf(GetIndexShopListBeanList.get(position).getShopname()));
//            holder.tuijian_score.setText(String.valueOf(GetIndexShopListBeanList.get(position).getScore()));
//            holder.tuijian_num.setText("总销量" + GetIndexShopListBeanList.get(position).getSalecount());
//            holder.tuijian_jvli.setText("" + GetIndexShopListBeanList.get(position).getJuli());
//            holder.tuijian_price.setText("¥" + GetIndexShopListBeanList.get(position).getPrice());
//            holder.tuijian_yhnum.setText(GetIndexShopListBeanList.get(position).getAllcount() + "个优惠项目");
//            Picasso.with(viewS.getContext())
//                    .load(String.valueOf(GetIndexShopListBeanList.get(position).getLogo()))
//                    .fit()
//                    .into(holder.iv_shop);
//            holder.ll_shop_item.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    Intent intent = new Intent(viewS.getContext(), StoreDetailsNewActivity.class);
//                    intent.putExtra("dianpu", String.valueOf(GetIndexShopListBeanList.get(position).getShopid()));
//                    startActivityForResult(intent, 6);
//                }
//            });
//
//
//        }
//
//        @Override
//        public int getItemCount() {
//            return GetIndexShopListBeanList.size();
//        }
//
//        class ViewHolder extends RecyclerView.ViewHolder {
//            private final RecyclerView RecyclerView_lable_new;
//            private final RecyclerView RecyclerView_shop_new;
//            private final TextView tuijian_title;
//            private final TextView tuijian_score;
//            private final TextView tuijian_num;
//            private final TextView tuijian_jvli;
//            private final TextView tuijian_price;
//            private final TextView tuijian_yhnum;
//            private final CustomRoundAngleImageView iv_shop;
//            private final LinearLayout ll_shop_item;
//
//            public ViewHolder(@NonNull View itemView) {
//                super(itemView);
//                RecyclerView_lable_new = (RecyclerView) itemView.findViewById(R.id.RecyclerView_lable_new);
//                RecyclerView_shop_new = (RecyclerView) itemView.findViewById(R.id.RecyclerView_shop_new);
//                tuijian_title = (TextView) itemView.findViewById(R.id.tuijian_title);
//                tuijian_score = (TextView) itemView.findViewById(R.id.tuijian_score);
//                tuijian_num = (TextView) itemView.findViewById(R.id.tuijian_num);
//                tuijian_jvli = (TextView) itemView.findViewById(R.id.tuijian_jvli);
//                tuijian_price = (TextView) itemView.findViewById(R.id.tuijian_price);
//                tuijian_yhnum = (TextView) itemView.findViewById(R.id.tuijian_yhnum);
//                iv_shop = (CustomRoundAngleImageView) itemView.findViewById(R.id.iv_shop);
//                ll_shop_item = (LinearLayout) itemView.findViewById(R.id.ll_shop_item);
//
//            }
//        }
//    }








//    private void GetIndexShopList() {
//        OkHttpUtils
//                .post()
//                .url(ServerApi.getIndexShopList)
//                .addParams("city", city1)
//                .addParams("p", String.valueOf(page))
//                .addParams("pxtype", String.valueOf(pxtype))
//                .addParams("lng", Longitude)
//                .addParams("lat", Latitude)
//                .build()
//                .execute(new StringCallback() {
//                    private JSONArray ary;
//                    private String data;
//                    private String message;
//                    private String codes;
//
//                    @Override
//                    public void onError(Call call, Exception e, int id) {
//
//                    }
//
//                    @Override
//                    public void onResponse(String response, int id) {
//                        try {
//                            codes = new JSONObject(response).getString("code");
//                            JSONObject root2 = new JSONObject(response);
//                            ary = root2.getJSONArray("data");
//                            message = new JSONObject(response).getString("message");
//
//
//                        } catch (JSONException e) {
//                            e.printStackTrace();
//                        }
//                        if (codes.equals("1")) {
//                            details_list = new ArrayList<>();
//                            details_list.add(data);
//
//                            Gson gson = new Gson();
//                            ArrayList<GetIndexShopListBean> outlinesGetIndexshop = gson.fromJson(String.valueOf(ary), new TypeToken<ArrayList<GetIndexShopListBean>>() {
//                            }.getType());
//                            for (int i = 0; i < outlinesGetIndexshop.size(); i++) {
//                                GetIndexShopListBean appoIntInfoBean = outlinesGetIndexshop.get(i);
//                                GetIndexShopListBeanList.add(new GetIndexShopListBean(
//                                        appoIntInfoBean.getShopid(),
//                                        appoIntInfoBean.getLogo(),
//                                        appoIntInfoBean.getShopname(),
//                                        appoIntInfoBean.getLabel(),
//                                        appoIntInfoBean.getScore(),
//                                        appoIntInfoBean.getSalecount(),
//                                        appoIntInfoBean.getJuli(),
//                                        appoIntInfoBean.getLng(),
//                                        appoIntInfoBean.getLat(),
//                                        appoIntInfoBean.getPrice(),
//                                        appoIntInfoBean.getAddress(),
//                                        appoIntInfoBean.getShopwl(),
//                                        appoIntInfoBean.getAllcount(),
//                                        appoIntInfoBean.getItemlist()
//
//                                ));
//                            }
//                            InitShopView();
//                        } else {
//                            Toast.makeText(viewS.getContext(), message, Toast.LENGTH_SHORT).show();
//                        }
//
//                    }
//                });
//
//    }

//    private void InitShopView() {
//        if (page == 1) {
//            //推荐门店列表
//            GridLayoutManager layoutManager2 = new GridLayoutManager(viewS.getContext(), 1) {
//                @Override
//                public boolean canScrollVertically() {
//                    return false;
//
//                }
//            };
//
//            layoutManager2.setOrientation(LinearLayoutManager.VERTICAL);
//            tuijian_md_recyclerView.setLayoutManager(layoutManager2);
//            adaptertuijian1 = new Fltuijian_Adapter();
//            tuijian_md_recyclerView.setAdapter(adaptertuijian1);
//        } else {
//            adaptertuijian1.notifyDataSetChanged();
//        }
//
//    }

    private void setView() {
        Viewpager_sy = viewS.findViewById(R.id.Viewpager_sy1);
        vp_layout = viewS.findViewById(R.id.vp_layout);
        city_sy = viewS.findViewById(R.id.city_sy);
        RecyclerView_homepage_new = viewS.findViewById(R.id.RecyclerView_homepage_new);
        iv_page = viewS.findViewById(R.id.iv_page);
        rl_midet = viewS.findViewById(R.id.rl_midet);
        iv_midet1 = viewS.findViewById(R.id.iv_midet1);
        iv_midet2 = viewS.findViewById(R.id.iv_midet2);
        mr_recyclerView = viewS.findViewById(R.id.mr_recyclerView);
        RecyclerView_jingxuan = viewS.findViewById(R.id.RecyclerView_jingxuan);

//        loading_rl = viewS.findViewById(R.id.loading_rl);
//        avi = viewS.findViewById(R.id.avi);
        tuijian_md_recyclerView = viewS.findViewById(R.id.tuijian_md_recyclerView);
        bt_jvli = viewS.findViewById(R.id.bt_jvli);
        bt_zonghe = viewS.findViewById(R.id.bt_zonghe);
        bt_pingfen = viewS.findViewById(R.id.bt_pingfen);
        bt_xiaoliang = viewS.findViewById(R.id.bt_xiaoliang);
        page_RefreshLayout = viewS.findViewById(R.id.page_RefreshLayout);
        bt_zonghe_table = viewS.findViewById(R.id.bt_zonghe_table);
        bt_jvli_table = viewS.findViewById(R.id.bt_jvli_table);
        bt_xiaoliang_table = viewS.findViewById(R.id.bt_xiaoliang_table);
        bt_pingfen_table = viewS.findViewById(R.id.bt_pingfen_table);
        ll_table = viewS.findViewById(R.id.ll_table);
        page_ScrollView = viewS.findViewById(R.id.page_ScrollView);
        rl_hight = viewS.findViewById(R.id.rl_hight);
        one_rl = viewS.findViewById(R.id.one_rl);
        two_ll = viewS.findViewById(R.id.two_ll);
        four_ll = viewS.findViewById(R.id.four_ll);
        five_ll = viewS.findViewById(R.id.five_ll);
        main_page_ss = viewS.findViewById(R.id.main_page_ss);

        LL_sy = viewS.findViewById(R.id.LL_sy);
        city_sy = viewS.findViewById(R.id.city_sy);
        tuijian_md_recyclerView.addItemDecoration(new SpaceItemDecoration(30));
//        avi.show();
//        avi.setVisibility(View.VISIBLE);
//        loading_rl.setVisibility(View.VISIBLE);
    }

//    private void startLocate() {
//        mLocationClient = new LocationClient(viewS.getContext());     //声明LocationClient类
//        mLocationClient.registerLocationListener(myListener);    //注册监听函数
//        LocationClientOption option = new LocationClientOption();
//        option.setLocationMode(LocationClientOption.LocationMode.Battery_Saving
//        );//可选，默认高精度，设置定位模式，高精度，低功耗，仅设备
//        option.setCoorType("gcj02");//可选，默认gcj02，设置返回的定位结果坐标系
//        int span = 10000;
////        option.setScanSpan(2);//可选，默认0，即仅定位一次，设置发起定位请求的间隔需要大于等于1000ms才是有效的
//        option.setIsNeedAddress(true);//可选，设置是否需要地址信息，默认不需要
//        option.setOpenGps(true);//可选，默认false,设置是否使用gps
//        option.setLocationNotify(true);//可选，默认false，设置是否当GPS有效时按照1S/1次频率输出GPS结果
//        option.setIsNeedLocationDescribe(true);//可选，默认false，设置是否需要位置语义化结果，可以在BDLocation.getLocationDescribe里得到，结果类似于“在北京天安门附近”
//        option.setIsNeedLocationPoiList(true);//可选，默认false，设置是否需要POI结果，可以在BDLocation.getPoiList里得到
//        option.setIgnoreKillProcess(false);//可选，默认true，定位SDK内部是一个SERVICE，并放到了独立进程，设置是否在stop的时候杀死这个进程，默认不杀死
//        option.SetIgnoreCacheException(false);//可选，默认false，设置是否收集CRASH信息，默认收集
//        option.setEnableSimulateGps(false);//可选，默认false，设置是否需要过滤GPS仿真结果，默认需要
//        mLocationClient.setLocOption(option);
//        //开启定位
//        mLocationClient.start();
//    }
//
//    private class MyLocationListener implements BDLocationListener {
//        @Override
//        public void onReceiveLocation(BDLocation location) {
//            SharedPreferences.Editor editor = getActivity().getSharedPreferences("disc_address", MODE_PRIVATE).edit();
//            editor.putString("Latitude", String.valueOf(location.getLatitude()));
//            editor.putString("Longitude", String.valueOf(location.getLongitude()));
//            editor.putString("city", String.valueOf(location.getCity()));
//
//            editor.commit();
//            if (city.equals("")) {
//                city1 = "沈阳";
//            } else {
//                city1 = city;
//            }
//            city_sy.setText(city1);
//
//        }
//
//    }

//    private void GetIndexInfo() {
//        String code = Installation.id(viewS.getContext());
//        SharedPreferences sp = viewS.getContext().getSharedPreferences("disc_address", MODE_PRIVATE);
//        Latitude = sp.getString("Latitude", "");
//        Longitude = sp.getString("Longitude", "");
//        city = sp.getString("city", "");
//        OkHttpUtils
//                .post()
//                .url(ServerApi.getIndexInfo)
//                .addParams("city", city1)
//                .addParams("code", code)
//                .addParams("type", "2")
//                .addParams("isnew", "1")
//                .addParams("lng", Longitude)
//                .addParams("lat", Latitude)
//                .build()
//                .execute(new StringCallback() {
//
//                    private String codes;
//                    private String message;
//
//                    @Override
//                    public void onError(Call call, Exception e, int id) {
//
//                    }
//
//                    @Override
//                    public void onResponse(String response, int id) {
//                        try {
//                            codes = new JSONObject(response).getString("code");
//                            message = new JSONObject(response).getString("message");
//                        } catch (JSONException e) {
//                            e.printStackTrace();
//                        }
//                        if (codes.equals("1")) {
//                            details_list = new ArrayList<>();
//                            details_list.add(response);
//                            GetCartItemPlistBeanList = new ArrayList<>();
//                            Gson gson = new Gson();
//                            outlinesGetIndex = gson.fromJson(String.valueOf(details_list), new TypeToken<ArrayList<GetIndexInfoBeanNewBean>>() {
//                            }.getType());
//                            for (int i = 0; i < outlinesGetIndex.size(); i++) {
//                                GetIndexInfoBeanNewBean appoIntInfoBean = outlinesGetIndex.get(i);
//                                GetCartItemPlistBeanList.add(new GetIndexInfoBeanNewBean(
//                                        appoIntInfoBean.getCode(),
//                                        appoIntInfoBean.getData(),
//                                        appoIntInfoBean.getMsg()
//
//                                ));
//                            }
//
//                            initView();
//
//                        } else {
//                            Toast.makeText(viewS.getContext(), message, Toast.LENGTH_SHORT).show();
//                        }
//
//
//                    }
//                });
//    }

//    private void initView() {
//
//        main_page_ss.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
////                Intent intent = new Intent(view.getContext(), SearchActivity.class);
////
////                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
////                intent.putExtra("type","0");
////                startActivityForResult(intent, 2);
//            }
//        });
//
//        page_ScrollView.setOnScrollListener(new MyScrollView.OnScrollListener() {
//            @Override
//            public void onScroll(int scrollY) {
////                if (GetCartItemPlistBeanList.get(0).getData().getNewitemlist1().size() == 0){
////                    ifour = 0;
////                    ithree = four_ll.getMeasuredHeight()+180;
////                }else {
////                    ithree = four_ll.getMeasuredHeight()+200;
////                    ifour = five_ll.getMeasuredHeight();
////                }
////
////                inoe = one_rl.getMeasuredHeight();
////                itwo = two_ll.getMeasuredHeight();
////                int hight=inoe + itwo + ithree + ifour;
////                int height2=hight;
////                int i = dip2px(getActivity(), scrollY);
////                int dp = px2dp(getActivity(), i);
////                if (dp > height2) {
////                    ll_table.setVisibility(View.VISIBLE);
////                    ViewGroup.LayoutParams params = rl_hight.getLayoutParams();
////                    params.height = 242;
////                    rl_hight.setLayoutParams(params);
////                } else {
////                    ll_table.setVisibility(View.GONE);
////                    ViewGroup.LayoutParams params = rl_hight.getLayoutParams();
////                    params.height = 135;
////                    rl_hight.setLayoutParams(params);
////                }
////                if (dp > 30) {
////                    iv_zd.setVisibility(View.VISIBLE);
////                    iv_zd.setOnClickListener(new View.OnClickListener() {
////                        @Override
////                        public void onClick(View view) {
////                            page_ScrollView.scrollTo(0, 0);// 改变滚动条的位置
////                        }
////                    });
////                } else {
////                    iv_zd.setVisibility(View.GONE);
////                }
//
//            }
//        });
//        page_RefreshLayout.setEnableRefresh(false);
//
//        page_RefreshLayout.setRefreshFooter(new BallPulseFooter(viewS.getContext()).setSpinnerStyle(SpinnerStyle.FixedBehind));
//        page_RefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
//            @Override
//            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
//                page_RefreshLayout.finishLoadMore(200);
//                page++;
////                GetIndexShopList();
//            }
//        });
//
//        bt_zonghe_table.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
////                bt_zonghe.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_zonghe_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_pingfen.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
//                bt_zonghe.setTextColor(Color.parseColor("#ffffff"));
//                bt_zonghe_table.setTextColor(Color.parseColor("#ffffff"));
//                bt_pingfen.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen_table.setTextColor(Color.parseColor("#000000"));
//                bt_jvli.setTextColor(Color.parseColor("#000000"));
//                bt_jvli_table.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang_table.setTextColor(Color.parseColor("#000000"));
//                pxtype = 0;
//                page = 1;
////                GetIndexShopListBeanList = new ArrayList<>();
////                GetIndexShopList();
//            }
//        });
//        bt_pingfen_table.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
////                bt_zonghe.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_zonghe_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_pingfen_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_jvli.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
//                bt_zonghe.setTextColor(Color.parseColor("#000000"));
//                bt_zonghe_table.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen.setTextColor(Color.parseColor("#ffffff"));
//                bt_pingfen_table.setTextColor(Color.parseColor("#ffffff"));
//                bt_jvli.setTextColor(Color.parseColor("#000000"));
//                bt_jvli_table.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang_table.setTextColor(Color.parseColor("#000000"));
//                page = 1;
//                pxtype = 3;
////                GetIndexShopListBeanList = new ArrayList<>();
////                GetIndexShopList();
//            }
//        });
//        bt_jvli_table.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
////                bt_zonghe.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_zonghe_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_jvli_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_xiaoliang.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
//                bt_zonghe.setTextColor(Color.parseColor("#000000"));
//                bt_zonghe_table.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen_table.setTextColor(Color.parseColor("#000000"));
//                bt_jvli.setTextColor(Color.parseColor("#ffffff"));
//                bt_jvli_table.setTextColor(Color.parseColor("#ffffff"));
//                bt_xiaoliang.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang_table.setTextColor(Color.parseColor("#000000"));
//                page = 1;
//                pxtype = 1;
////                GetIndexShopListBeanList = new ArrayList<>();
////                GetIndexShopList();
//            }
//        });
//        bt_xiaoliang_table.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
////                bt_zonghe.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_zonghe_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_xiaoliang_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
//                bt_zonghe.setTextColor(Color.parseColor("#000000"));
//                bt_zonghe_table.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen_table.setTextColor(Color.parseColor("#000000"));
//                bt_jvli_table.setTextColor(Color.parseColor("#000000"));
//                bt_jvli.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang.setTextColor(Color.parseColor("#ffffff"));
//                bt_xiaoliang_table.setTextColor(Color.parseColor("#ffffff"));
//                page = 1;
//                pxtype = 2;
////                GetIndexShopListBeanList = new ArrayList<>();
////                GetIndexShopList();
//            }
//        });
//        //分类点击事件
//
//        bt_zonghe.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
////                bt_zonghe.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_zonghe_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_pingfen.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
//                bt_zonghe.setTextColor(Color.parseColor("#ffffff"));
//                bt_zonghe_table.setTextColor(Color.parseColor("#ffffff"));
//                bt_pingfen.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen_table.setTextColor(Color.parseColor("#000000"));
//                bt_jvli.setTextColor(Color.parseColor("#000000"));
//                bt_jvli_table.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang_table.setTextColor(Color.parseColor("#000000"));
//                pxtype = 0;
//                page = 1;
////                GetIndexShopListBeanList = new ArrayList<>();
////                GetIndexShopList();
//            }
//        });
//        bt_pingfen.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
////                bt_zonghe.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_zonghe_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_pingfen_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_jvli.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
//                bt_zonghe.setTextColor(Color.parseColor("#000000"));
//                bt_zonghe_table.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen.setTextColor(Color.parseColor("#ffffff"));
//                bt_pingfen_table.setTextColor(Color.parseColor("#ffffff"));
//                bt_jvli.setTextColor(Color.parseColor("#000000"));
//                bt_jvli_table.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang_table.setTextColor(Color.parseColor("#000000"));
//                page = 1;
//                pxtype = 3;
//                GetIndexShopListBeanList = new ArrayList<>();
//                GetIndexShopList();
//            }
//        });
//        bt_jvli.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
////                bt_zonghe.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_zonghe_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_jvli_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_xiaoliang.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
//                bt_zonghe.setTextColor(Color.parseColor("#000000"));
//                bt_zonghe_table.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen_table.setTextColor(Color.parseColor("#000000"));
//                bt_jvli.setTextColor(Color.parseColor("#ffffff"));
//                bt_jvli_table.setTextColor(Color.parseColor("#ffffff"));
//                bt_xiaoliang.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang_table.setTextColor(Color.parseColor("#000000"));
//                page = 1;
//                pxtype = 1;
////                GetIndexShopListBeanList = new ArrayList<>();
////                GetIndexShopList();
//            }
//        });
//        bt_xiaoliang.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
////                bt_zonghe.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_zonghe_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_pingfen_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_jvli_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_bai);
////                bt_xiaoliang.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
////                bt_xiaoliang_table.setBackgroundResource(R.drawable.shape_bt_tuiji_bg_red);
//                bt_zonghe.setTextColor(Color.parseColor("#000000"));
//                bt_zonghe_table.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen.setTextColor(Color.parseColor("#000000"));
//                bt_pingfen_table.setTextColor(Color.parseColor("#000000"));
//                bt_jvli_table.setTextColor(Color.parseColor("#000000"));
//                bt_jvli.setTextColor(Color.parseColor("#000000"));
//                bt_xiaoliang.setTextColor(Color.parseColor("#ffffff"));
//                bt_xiaoliang_table.setTextColor(Color.parseColor("#ffffff"));
//                page = 1;
//                pxtype = 2;
////                GetIndexShopListBeanList = new ArrayList<>();
////                GetIndexShopList();
//            }
//        });
////        精选好货列表适配器
////
////        if (GetCartItemPlistBeanList.get(0).getData().getNewitemlist1().size() == 0) {
////            five_ll.setVisibility(View.GONE);
////        } else {
////            five_ll.setVisibility(View.VISIBLE);
////            layoutManager6 = new LinearLayoutManager(viewS.getContext());
////            layoutManager6.setOrientation(LinearLayoutManager.HORIZONTAL);
////            RecyclerView_jingxuan.setLayoutManager(layoutManager6);
////            mr1_adapter = new Mr1_Adapter();
////            RecyclerView_jingxuan.setAdapter(mr1_adapter);
////        }
////
////
//////发现好店列表适配器初始化
////
////        layoutManager2 = new LinearLayoutManager(viewS.getContext());
////        layoutManager2.setOrientation(LinearLayoutManager.HORIZONTAL);
////        mr_recyclerView.setLayoutManager(layoutManager2);
////        mr_adapter = new Mr_Adapter();
////        mr_recyclerView.setAdapter(mr_adapter);
//
////
//////        tuijian_md_recyclerView
////        if (GetCartItemPlistBeanList.get(0).getData().getMidtype() == 0) {
////            rl_midet.setVisibility(View.GONE);
////        } else {
////            rl_midet.setVisibility(View.VISIBLE);
////            Picasso.with(viewS.getContext())
////                    .load(String.valueOf(GetCartItemPlistBeanList.get(0).getData().getMidimg().getZuo().getImgsrc()))
////                    .fit()
////                    .into(iv_midet1);
////            Picasso.with(viewS.getContext())
////                    .load(String.valueOf(GetCartItemPlistBeanList.get(0).getData().getMidimg().getYou().getImgsrc()))
////                    .fit()
////                    .into(iv_midet2);
////        }
//        iv_midet2.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//
//            }
//        });
//        iv_midet1.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//            }
//        });
//
//
////        //首页广告图片
////        Picasso.with(viewS.getContext())
////                .load(String.valueOf(GetCartItemPlistBeanList.get(0).getData().getShowimg().getImgsrc()))
////                .fit()
////                .into(iv_page);
//        //初始化轮播图
////        init();
////        vp_layout.setVisibility(View.VISIBLE);
////        Viewpager_sy.setVisibility(View.VISIBLE);
////        GridLayoutManager layoutManagertj = new GridLayoutManager(viewS.getContext(), 5) {
////            @Override
////            public boolean canScrollVertically() {
////                return false;
////
////            }
////        };
////
////        layoutManagertj.setOrientation(LinearLayoutManager.VERTICAL);
////        RecyclerView_homepage_new.setLayoutManager(layoutManagertj);
////        adaptertuijian = new page_Adapter();
////
////        RecyclerView_homepage_new.setAdapter(adaptertuijian);
//
//
//    }

    private void init() {
        mContext = viewS.getContext();
        viewPagerItemSize = BannerListBeanList.get(0).getData().size();
        if (viewPagerItemSize > 0) {
            initDots();
            initViewPager();
            setAutoChangeViewPager();
        }

    }

    public static class Installation {
        private static String sID = null;
        private static final String INSTALLATION = "INSTALLATION";

        public synchronized static String id(Context context) {
            if (sID == null) {
                File installation = new File(context.getFilesDir(), INSTALLATION);
                try {
                    if (!installation.exists()) writeInstallationFile(installation);
                    sID = readInstallationFile(installation);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            return sID;
        }

        private static String readInstallationFile(File installation) throws IOException {
            RandomAccessFile f = new RandomAccessFile(installation, "r");
            byte[] bytes = new byte[(int) f.length()];
            f.readFully(bytes);
            f.close();
            return new String(bytes);
        }

        private static void writeInstallationFile(File installation) throws IOException {
            FileOutputStream out = new FileOutputStream(installation);
            String id = UUID.randomUUID().toString();
            out.write(id.getBytes());
            out.close();
        }
    }

    //初始化ViewPager
    @SuppressLint("ClickableViewAccessibility")
    private void initViewPager() {
//        mViewPager = (ViewPager) findViewById(R.id.guide_viewpager);
        mViewPagerAdapter = new LauncherViewPagerSYNewAdapter(viewS.getContext());
        mViewPagerAdapter.setAdapterData(BannerListBeanList.get(0).getData());

        Viewpager_sy.setAdapter(mViewPagerAdapter);

        int currentItem = Integer.MAX_VALUE / 2 - Integer.MAX_VALUE / 2 % viewPagerItemSize;
        Viewpager_sy.setCurrentItem(0);
        setdotImageViews(currentItem % viewPagerItemSize);
        Viewpager_sy.setOnTouchListener(new View.OnTouchListener() {
            long downTime;
            int downX;

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                Viewpager_sy.requestDisallowInterceptTouchEvent(true);
                switch (motionEvent.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        Log.e("TAG", "==========用户滑动item");
                        //记录按下的坐标
                        downX = (int) motionEvent.getX();
                        //记录按下的时间
                        downTime = System.currentTimeMillis();
                        break;
                    case MotionEvent.ACTION_UP:
                        int item = Viewpager_sy.getCurrentItem();
                        if (System.currentTimeMillis() - downTime < 500
                                && Math.abs(downX - motionEvent.getX()) < 30) {
                            Log.e("TAG", "==============item=" + item);

                        }


                        break;
                    default:
                        break;
                }

                return false;
            }
        });
//        Viewpager_sy.setOnTouchListener(new View.OnTouchListener() {
//            @Override
//            public boolean onTouch(View arg0, MotionEvent arg1) {
//                Viewpager_sy.requestDisallowInterceptTouchEvent(true);
//                Toast.makeText(mContext, (CharSequence) arg0, Toast.LENGTH_SHORT).show();
//                return false;
//            }
//        });
    }

    //初始化底部小圆点
    private void initDots() {

        dotImageViews = new ImageView[viewPagerItemSize];
        for (int i = 0; i < dotImageViews.length; i++) {
            LinearLayout layout = new LinearLayout(mContext);
            ImageView imageView = new ImageView(mContext);
            imageView.setLayoutParams(new ViewGroup.LayoutParams(20, 20));
            if (i == 0) {
                imageView.setBackgroundResource(R.drawable.dot_focus);
            } else {

                imageView.setBackgroundResource(R.drawable.dot_normal);
            }
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(15, 15);
            params.setMargins(10, 7, 7, 7);
            imageView.setLayoutParams(params);
            dotImageViews[i] = imageView;
            layout.addView(imageView);
            vp_layout.addView(layout);
        }
    }


    //开启ViewPager的自动轮播
    @SuppressLint("HandlerLeak")

    @SuppressWarnings("deprecation")
    private void setAutoChangeViewPager() {
        mPageChangeListenerImpl = new PageChangeListenerImpl();
        Viewpager_sy.setOnPageChangeListener(mPageChangeListenerImpl);

        mHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                switch (msg.what) {
                    case SET_VIEWPAGER_ITEM:
                        if (Viewpager_sy != null && mViewPagerAdapter != null) {
                            int currentItemIndex = Viewpager_sy.getCurrentItem();
                            int itemsCount = mViewPagerAdapter.getCount();
                            if ((currentItemIndex + 1) < itemsCount) {
                                Viewpager_sy.setCurrentItem(currentItemIndex + 1, true);

                            } else {
                                Viewpager_sy.setCurrentItem(0, false);
                            }
                        }
                        break;
                }
            }
        };

        mRunnable = new Runnable() {
            @Override
            public void run() {
                Message message = mHandler.obtainMessage();
                message.what = SET_VIEWPAGER_ITEM;
                mHandler.sendMessage(message);
                mHandler.removeCallbacks(mRunnable);
                mHandler.postDelayed(this, INTERVAL);
            }
        };

        mHandler.postDelayed(mRunnable, INTERVAL);
    }


    //设置小圆点的显示
    private void setdotImageViews(int selected) {
        for (int i = 0; i < dotImageViews.length; i++) {
            dotImageViews[selected].setBackgroundResource(R.drawable.dot_focus);
            if (selected != i) {
                dotImageViews[i].setBackgroundResource(R.drawable.dot_normal);
            }
        }
    }

    //ViewPager翻页后更新小圆点的显示
    private class PageChangeListenerImpl implements ViewPager.OnPageChangeListener {
        @Override
        public void onPageSelected(int selected) {
            setdotImageViews(selected % viewPagerItemSize);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }

    }

//    private class page_Adapter extends RecyclerView.Adapter<page_Adapter.ViewHolder> {
//        @NonNull
//        @Override
//        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.like_page, parent, false);
//
//            ViewHolder holder = new ViewHolder(view);
////            int parentHeight = parent.getWidth();
////            parent.getWidth();
////            ViewGroup.LayoutParams layoutParams = holder.itemView.getLayoutParams();
////
////            layoutParams.width = (parentHeight / 5);
//            return holder;
//        }
//
//        @Override
//        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//
//            holder.tv_page.setText(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getTitle());
////
//            Picasso.with(viewS.getContext())
//                    .load(String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getIconsrc()))
//                    .fit()
//                    .into(holder.iv_page);
////            Glide.with(viewS.getContext()).load(String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getIconsrc())).into(holder.iv_page);
//            holder.page_item.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                    if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 0) {
//                        Intent intent = new Intent(viewS.getContext(), CommodityDetailsActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("Shop_id", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        startActivity(intent);
//                    } else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 1) {
//                        Intent intent = new Intent(viewS.getContext(), StoreDetailsActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("dianpu", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        startActivityForResult(intent, 6);
//                    } else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 2) {
//                        Intent intent = new Intent(viewS.getContext(), ProductListActiviyt.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("title", "");
//                        intent.putExtra("classid", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        startActivityForResult(intent, 6);
//                    } else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 3) {
//                        Intent intent = new Intent(viewS.getContext(), NewGiftBagActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        startActivityForResult(intent, 100);
//                    } else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 4) {
//                        Intent intent = new Intent(viewS.getContext(), ZSWebViewActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("url", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        intent.putExtra("title", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getToptitle()));
//                        startActivityForResult(intent, 100);
//                    } else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 5) {
//                        Intent intent = new Intent(viewS.getContext(), DiscountTicketsActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        startActivityForResult(intent, 2);
//                    } else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 5) {
//                        Intent intent = new Intent(viewS.getContext(), DiscountTicketsActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        startActivityForResult(intent, 2);
//                    } else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 6) {
//                        Intent intent = new Intent(viewS.getContext(), FoodColumnActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        startActivityForResult(intent, 2);
//                    } else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 7) {
//                        Intent intent = new Intent(viewS.getContext(), QualityLifeActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        startActivityForResult(intent, 2);
//                    } else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 8) {
//                        Intent intent = new Intent(viewS.getContext(), CarWashActivity.class);
//                        intent.putExtra("classid", " ");
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        startActivityForResult(intent, 2);
//                    } else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 9) {
//                        Intent intent = new Intent(viewS.getContext(), GoodValueGoodsActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        startActivityForResult(intent, 2);
//                    }else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType()== 10) {
//                        Intent intent = new Intent(viewS.getContext(), NewClassificationActivity.class);
//                        intent.putExtra("classid", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        startActivityForResult(intent, 2);
//                    }else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 11) {
//                        Intent intent = new Intent(viewS.getContext(), NewClassSpringActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("classid", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        startActivityForResult(intent, 2);
//                    }
//                    else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType()== 12) {
//                        Intent intent = new Intent(viewS.getContext(), NewClassParentingActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("classid", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        startActivityForResult(intent, 2);
//                    }
//                    else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 13) {
//                        Intent intent = new Intent(viewS.getContext(), NewClassLeisureTimeActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("classid", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        startActivityForResult(intent, 2);
//                    }
//                    else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 14) {
//                        Intent intent = new Intent(viewS.getContext(), NewClassFeliciousFoodActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("classid", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        startActivityForResult(intent, 2);
//                    }
//                    else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 15) {
//                        Intent intent = new Intent(viewS.getContext(), NewClassCarWashActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("classid", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        startActivityForResult(intent, 2);
//                    }
//                    else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType() == 16) {
//                        Intent intent = new Intent(viewS.getContext(), NewClassCarInspectionActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("classid", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        startActivityForResult(intent, 2);
//                    }
//                    else if (GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType()== 17) {
//                        Intent intent = new Intent(viewS.getContext(), NewClassManicureActivity.class);
//                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                        intent.putExtra("classid", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getAppurl().get(GetCartItemPlistBeanList.get(0).getData().getIconlist().get(position).getType())));
//                        startActivityForResult(intent, 2);
//                    }
//                }
//            });
//            avi.hide();
//            loading_rl.setVisibility(View.GONE);
//
//        }
//
//        @Override
//        public int getItemCount() {
//            return GetCartItemPlistBeanList.get(0).getData().getIconlist().size();
//        }
//
//        class ViewHolder extends RecyclerView.ViewHolder {
//
//
//            private final MyTextView tv_page;
//            private final ImageView iv_page;
//            private final LinearLayout page_item;
//
//
//            public ViewHolder(@NonNull View itemView) {
//                super(itemView);
//                iv_page = (ImageView) itemView.findViewById(R.id.iv_page);
//                tv_page = (MyTextView) itemView.findViewById(R.id.tv_page);
//                page_item = (LinearLayout) itemView.findViewById(R.id.page_item);
//
//            }
//        }
//    }

    /*
     * 生活服务适配器
     * */
    private class Mr_Adapter extends RecyclerView.Adapter<Mr_Adapter.ViewHolder> {


        @NonNull
        @Override
        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.page_rv_mr, parent, false);

            ViewHolder holder = new ViewHolder(view);
            int parentHeight = parent.getWidth();
            parent.getWidth();
            ViewGroup.LayoutParams layoutParams = holder.itemView.getLayoutParams();

            layoutParams.width = (int) (parentHeight / 3.9);
            return holder;
        }

        @Override
        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

            holder.mr_tv_title.setText(recommendGoodsListBeanList.get(0).getData().getData().get(position).getTitle());
            holder.mr_tv_jiage.setText("¥" + recommendGoodsListBeanList.get(0).getData().getData().get(position).getPrice()+"起'");
//            if (GetCartItemPlistBeanList.get(0).getData().getNewitemlist().get(position).getOutprice().equals("")) {
                holder.mr_tv_old_jiage.setVisibility(View.GONE);
//            } else {
//                holder.mr_tv_old_jiage.setText("¥" + GetCartItemPlistBeanList.get(0).getData().getNewitemlist().get(position).getOutprice());
//                holder.mr_tv_old_jiage.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
//            }

            Picasso.with(viewS.getContext())
                    .load(String.valueOf("http://tbyg-new.oss-cn-beijing.aliyuncs.com/"+recommendGoodsListBeanList.get(0).getData().getData().get(position).getImage()))
                    .fit()
                    .into(holder.iv_mr);
//            Glide.with(viewS.getContext()).load(String.valueOf(GetCartItemPlistBeanList.get(0).getData().getNewitemlist().get(position).getShowimg())).into(holder.iv_mr);
//            holder.sx_item_page.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                    Intent intent = new Intent(viewS.getContext(), CommodityDetailsActivity.class);
//                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                    intent.putExtra("Shop_id", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getNewitemlist().get(position).getId()));
//                    viewS.getContext().startActivity(intent);
//                }
//            });
        }

        @Override
        public int getItemCount() {
            return recommendGoodsListBeanList.get(0).getData().getData().size();
        }

        class ViewHolder extends RecyclerView.ViewHolder {


            private final TextView mr_tv_old_jiage;
            private final TextView mr_tv_jiage;
            private final TextView mr_tv_title;
            private final CustomRoundAngleImageView iv_mr;
            private final RelativeLayout sx_item_page;


            public ViewHolder(@NonNull View itemView) {
                super(itemView);
                iv_mr = (CustomRoundAngleImageView) itemView.findViewById(R.id.iv_mr);
                mr_tv_title = (TextView) itemView.findViewById(R.id.mr_tv_title);
                mr_tv_jiage = (TextView) itemView.findViewById(R.id.mr_tv_jiage);
                mr_tv_old_jiage = (TextView) itemView.findViewById(R.id.mr_tv_old_jiage);
                sx_item_page = (RelativeLayout) itemView.findViewById(R.id.sx_item_page);

            }
        }
    }
    /*
     * 精选好货适配器
     * */

    private class Mr1_Adapter extends RecyclerView.Adapter<Mr1_Adapter.ViewHolder> {


        @NonNull
        @Override
        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.page_rv_mr, parent, false);

            ViewHolder holder = new ViewHolder(view);
            int parentHeight = parent.getWidth();
            parent.getWidth();
            ViewGroup.LayoutParams layoutParams = holder.itemView.getLayoutParams();

            layoutParams.width = (int) (parentHeight / 3.9);
            return holder;
        }

        @Override
        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

            holder.mr_tv_title.setText(RecommendStoreListBeanList.get(0).getData().getList().get(position).getName()    );
//            holder.mr_tv_jiage.setText("¥" + RecommendStoreListBeanList.get(0).getData().getList().get(position).());
//            if (GetCartItemPlistBeanList.get(0).getData().getNewitemlist1().get(position).getOutprice().equals("")) {
//                holder.mr_tv_old_jiage.setVisibility(View.GONE);
//            } else {
//                holder.mr_tv_old_jiage.setText("¥" + RecommendStoreListBeanList.get(0).getData().getNewitemlist1().get(position).getOutprice());
//                holder.mr_tv_old_jiage.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
//            }

            Picasso.with(viewS.getContext())
                    .load(String.valueOf("http://tbyg-new.oss-cn-beijing.aliyuncs.com/"+RecommendStoreListBeanList.get(0).getData().getList().get(position).getImages()))
                    .fit()
                    .into(holder.iv_mr);
//            holder.sx_item_page.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                    Intent intent = new Intent(viewS.getContext(), CommodityDetailsActivity.class);
//                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                    intent.putExtra("Shop_id", String.valueOf(GetCartItemPlistBeanList.get(0).getData().getNewitemlist1().get(position).getId()));
//                    viewS.getContext().startActivity(intent);
//                }
//            });
        }

        @Override
        public int getItemCount() {
            return RecommendStoreListBeanList.get(0).getData().getList().size();
        }

        class ViewHolder extends RecyclerView.ViewHolder {


            private final TextView mr_tv_old_jiage;
            private final TextView mr_tv_jiage;
            private final TextView mr_tv_title;
            private final CustomRoundAngleImageView iv_mr;
            private final RelativeLayout sx_item_page;


            public ViewHolder(@NonNull View itemView) {
                super(itemView);
                iv_mr = (CustomRoundAngleImageView) itemView.findViewById(R.id.iv_mr);
                mr_tv_title = (TextView) itemView.findViewById(R.id.mr_tv_title);
                mr_tv_jiage = (TextView) itemView.findViewById(R.id.mr_tv_jiage);
                mr_tv_old_jiage = (TextView) itemView.findViewById(R.id.mr_tv_old_jiage);
                sx_item_page = (RelativeLayout) itemView.findViewById(R.id.sx_item_page);

            }
        }
    }
    /*
     * 门店列表适配器
     * */

//    private class Fltuijian_Adapter extends RecyclerView.Adapter<Fltuijian_Adapter.ViewHolder> {
//
//
//        private SyLinearLayoutManager layoutManager_lable;
//        private lable_Adapter lable_adapter;
//        private SyLinearLayoutManager layoutManager_lable2;
//        private shop_Adapter shop_adapter;
//
//
//        @NonNull
//        @Override
//        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_new_page_shope, parent, false);
//
//            ViewHolder holder = new ViewHolder(view);
//
//            return holder;
//        }
//
//        @Override
//        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//            //lable初始化适配器
//            layoutManager_lable = new SyLinearLayoutManager(viewS.getContext());
//            layoutManager_lable.setOrientation(SyLinearLayoutManager.HORIZONTAL);
//            holder.RecyclerView_lable_new.setLayoutManager(layoutManager_lable);
//            lable_adapter = new lable_Adapter(position);
//            holder.RecyclerView_lable_new.setAdapter(lable_adapter);
//
//            //商品初始化适配器
//            layoutManager_lable2 = new SyLinearLayoutManager(viewS.getContext());
//            layoutManager_lable2.setOrientation(SyLinearLayoutManager.VERTICAL);
//            holder.RecyclerView_shop_new.setLayoutManager(layoutManager_lable2);
//            shop_adapter = new shop_Adapter(position);
//            holder.RecyclerView_shop_new.setAdapter(shop_adapter);
//
//            holder.tuijian_title.setText(String.valueOf(GetIndexShopListBeanList.get(position).getShopname()));
//            holder.tuijian_score.setText(String.valueOf(GetIndexShopListBeanList.get(position).getScore()));
//            holder.tuijian_num.setText("总销量" + GetIndexShopListBeanList.get(position).getSalecount());
//            holder.tuijian_jvli.setText("" + GetIndexShopListBeanList.get(position).getJuli());
//            holder.tuijian_price.setText("¥" + GetIndexShopListBeanList.get(position).getPrice());
//            holder.tuijian_yhnum.setText(GetIndexShopListBeanList.get(position).getAllcount() + "个优惠项目");
//            Picasso.with(viewS.getContext())
//                    .load(String.valueOf(GetIndexShopListBeanList.get(position).getLogo()))
//                    .fit()
//                    .into(holder.iv_shop);
//            holder.ll_shop_item.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    Intent intent = new Intent(viewS.getContext(), StoreDetailsNewActivity.class);
//                    intent.putExtra("dianpu", String.valueOf(GetIndexShopListBeanList.get(position).getShopid()));
//                    startActivityForResult(intent, 6);
//                }
//            });
//
//
//        }
//
//        @Override
//        public int getItemCount() {
//            return GetIndexShopListBeanList.size();
//        }
//
//        class ViewHolder extends RecyclerView.ViewHolder {
//            private final RecyclerView RecyclerView_lable_new;
//            private final RecyclerView RecyclerView_shop_new;
//            private final TextView tuijian_title;
//            private final TextView tuijian_score;
//            private final TextView tuijian_num;
//            private final TextView tuijian_jvli;
//            private final TextView tuijian_price;
//            private final TextView tuijian_yhnum;
//            private final CustomRoundAngleImageView iv_shop;
//            private final LinearLayout ll_shop_item;
//
//            public ViewHolder(@NonNull View itemView) {
//                super(itemView);
//                RecyclerView_lable_new = (RecyclerView) itemView.findViewById(R.id.RecyclerView_lable_new);
//                RecyclerView_shop_new = (RecyclerView) itemView.findViewById(R.id.RecyclerView_shop_new);
//                tuijian_title = (TextView) itemView.findViewById(R.id.tuijian_title);
//                tuijian_score = (TextView) itemView.findViewById(R.id.tuijian_score);
//                tuijian_num = (TextView) itemView.findViewById(R.id.tuijian_num);
//                tuijian_jvli = (TextView) itemView.findViewById(R.id.tuijian_jvli);
//                tuijian_price = (TextView) itemView.findViewById(R.id.tuijian_price);
//                tuijian_yhnum = (TextView) itemView.findViewById(R.id.tuijian_yhnum);
//                iv_shop = (CustomRoundAngleImageView) itemView.findViewById(R.id.iv_shop);
//                ll_shop_item = (LinearLayout) itemView.findViewById(R.id.ll_shop_item);
//
//            }
//        }
//    }
//    /*
//     * 门店列表lable适配器
//     * */
//
//    private class lable_Adapter extends RecyclerView.Adapter<lable_Adapter.ViewHolder> {
//
//
//        private int pos;
//
//        public lable_Adapter(int position) {
//            pos = position;
//        }
//
//        @NonNull
//        @Override
//        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_fl_lable, parent, false);
//
//            ViewHolder holder = new ViewHolder(view);
//
//            return holder;
//        }
//
//        @Override
//        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//            holder.bt_lable.setText(String.valueOf(GetIndexShopListBeanList.get(pos).getLabel().get(position)));
//
//        }
//
//        @Override
//        public int getItemCount() {
//            return GetIndexShopListBeanList.get(pos).getLabel().size();
//        }
//
//        class ViewHolder extends RecyclerView.ViewHolder {
//            private final TextView bt_lable;
//
//
//            public ViewHolder(@NonNull View itemView) {
//                super(itemView);
//
//                bt_lable = (TextView) itemView.findViewById(R.id.bt_lable);
//
//            }
//        }
//    }
//
//    /*
//     * 门店列表商品适配器
//     * */
//    private class shop_Adapter extends RecyclerView.Adapter<shop_Adapter.ViewHolder> {
//
//
//        private int pos;
//
//        public shop_Adapter(int position) {
//            pos = position;
//        }
//
//        @NonNull
//        @Override
//        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_page_shop, parent, false);
//
//            ViewHolder holder = new ViewHolder(view);
//
//            return holder;
//        }
//
//        @Override
//        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//            holder.tv_title.setText(String.valueOf(GetIndexShopListBeanList.get(pos).getItemlist().get(position).getTitle()));
//            holder.tv_color.setText(String.valueOf(GetIndexShopListBeanList.get(pos).getItemlist().get(position).getWord()));
//            Drawable normal = ContextCompat.getDrawable(requireContext(), R.drawable.shape_hope_hui_bg);
//            GradientDrawable normalGroup = (GradientDrawable) normal;
//            normalGroup.setColor(Color.parseColor(GetIndexShopListBeanList.get(pos).getItemlist().get(position).getWordcolor()));
//            holder.rl_bg.setBackground(normalGroup);
//            if (position == GetIndexShopListBeanList.get(pos).getItemlist().size() - 1) {
//                holder.shop_view.setVisibility(View.GONE);
//            } else {
//                holder.shop_view.setVisibility(View.VISIBLE);
//            }
//            holder.ll_shop.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    Intent intent = new Intent(viewS.getContext(), CommodityDetailsActivity.class);
//
//                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//                    intent.putExtra("Shop_id", String.valueOf(GetIndexShopListBeanList.get(pos).getItemlist().get(position).getBid()));
//                    startActivity(intent);
//                }
//
//            });
//        }
//
//        @Override
//        public int getItemCount() {
//            return GetIndexShopListBeanList.get(pos).getItemlist().size();
//        }
//
//        class ViewHolder extends RecyclerView.ViewHolder {
//
//            private final TextView tv_color;
//            private final TextView tv_title;
//            private final RelativeLayout rl_bg;
//            private final View shop_view;
//            private final LinearLayout ll_shop;
//
//
//            public ViewHolder(@NonNull View itemView) {
//                super(itemView);
//
//                tv_color = (TextView) itemView.findViewById(R.id.tv_color);
//                tv_title = (TextView) itemView.findViewById(R.id.tv_title);
//                rl_bg = (RelativeLayout) itemView.findViewById(R.id.rl_bg);
//                ll_shop = (LinearLayout) itemView.findViewById(R.id.ll_shop);
//                shop_view = (View) itemView.findViewById(R.id.shop_view);
//
//            }
//        }
//    }

    class SpaceItemDecoration extends RecyclerView.ItemDecoration {
        int mSpace;

        /**
         * Retrieve any offsets for the given item. Each field of <code>outRect</code> specifies
         * the number of pixels that the item view should be inset by, similar to padding or margin.
         * The default implementation sets the bounds of outRect to 0 and returns.
         * <p>
         * <p>
         * If this ItemDecoration does not affect the positioning of item views, it should set
         * all four fields of <code>outRect</code> (left, top, right, bottom) to zero
         * before returning.
         * <p>
         * <p>
         * If you need to access Adapter for additional data, you can call
         * {@link RecyclerView#getChildAdapterPosition(View)} to get the adapter position of the
         * View.
         *
         * @param outRect Rect to receive the output.
         * @param view    The child view to decorate
         * @param parent  RecyclerView this ItemDecoration is decorating
         * @param state   The current state of RecyclerView.
         */
        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            super.getItemOffsets(outRect, view, parent, state);
            outRect.left = mSpace;
            outRect.right = mSpace;
            outRect.bottom = mSpace;
            if (parent.getChildAdapterPosition(view) == 0) {
                outRect.top = mSpace;
            }

        }

        public SpaceItemDecoration(int space) {
            this.mSpace = space;
        }
    }

    //将像素转换为px
    public static int dip2px(Context context, float dpValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }

    //将px转换为dp
    public static int px2dp(Context context, float pxValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }
    private void requestPermission(int cameraReqCode, int decode) {
        ActivityCompat.requestPermissions(
                (Activity) viewS.getContext(),
                new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE},
                cameraReqCode);

    }
}